package e2e

import (
	"testing"

	"github.com/lab-online/pkg/auth"
	"github.com/lab-online/pkg/e2e"
	"github.com/lab-online/pkg/resp"
	"github.com/stretchr/testify/assert"
)

func (ctx *context) defineDeleteRequest(
	username string,
	role auth.Role,
	deletedUsername string,
) *e2e.Request {
	return &e2e.Request{
		Method: "DELETE",
		Path:   ctx.Prefix + "/v1/users/" + deletedUsername,
		Header: map[string]string{
			"Authorization": ctx.GenBearerToken(username, role),
		},
	}
}

func (ctx *context) CaseDeleteUser1() (string, func(*testing.T)) {
	ctx.utilsCreateUser("00240302", auth.RoleAdmin, "12345678")
	request := ctx.defineDeleteRequest("admin001", auth.RoleAdmin, "00240302")
	return "软删除用户", func(t *testing.T) {
		response := ctx.JSONRequest(request)

		assert.Equal(t, 200, response.Code)

		body := e2e.JSONBodyParser[resp.SuccessRespBody[any]](response)

		assert.Equal(t, 20103, body.Code)
		assert.Empty(t, body.Data)
	}
}
